const submitBtn = document.getElementById('submit')
const usernameIpt = document.getElementById('username')
/*

const pwdIpt = document.getElementById('pwd')


// let usernameFlag = false
// let pwdFlag = false
let flag = {
    username:false,
    pwd:false
}
usernameIpt.onchange = function(){
    if(this.value.length <= 3){
        flag.username = false
    }else{
        flag.username = true
    }
}
pwdIpt.onchange = function(){
    if(this.value.length <= 3){
        flag.pwd = false
    }else{
        flag.pwd = true
    }
}


submitBtn.onclick = function(e){
    if(!flag.pwd || !flag.username){
        e.preventDefault()
        alert('信息填写错误')
    }
}
*/
/*
let iptsId = ["username", "pwd", "repPwd"]
//根据id的列表生成一个验证结果对象
function genValiRes(idList) {
    const valiRes = {}
    idList.forEach(function (id) {
        valiRes[id] = false
    })
    return valiRes
}
const valiRes = genValiRes(iptsId)
//给每个元素添加change事件，监听输入框改变。根据验证结果改变valiRes
iptsId.forEach(function (id) {
    const ipt = document.getElementById(id)
    ipt.onchange = function () {
        if (this.value.length <= 3) {
            valiRes[id] = false
        } else {
            valiRes[id]= true
        }
    }
})
*/
/**
 * 根据验证结果对象判断整个表单的验证是否通过
 * @param {Object} valiRes 
 */
// function validateRes(valiRes) {
//     for (let key in valiRes) {
//         const value = valiRes[key]
//         if (!value) {
//             return false
//         }
//     }
//     return true
// }
/**
 * 提交按钮
 */
// submitBtn.onclick = function (e) {
//     const res = validateRes(valiRes)
//     if (!res) {
//         e.preventDefault()
//         alert('信息填写错误')
//     }

// }
